import { Schema} from 'mongoose';
import { ChatTypes, ChatStatus } from '@/enums/chatEnums';

export const ChatHistorySchema = new Schema({
  // 聊天室id
  room: {
    type: Schema.Types.ObjectId,
    required: true,
    ref: 'chatRooms'
  },
  // 创建者
  creator: {
    type: Schema.Types.ObjectId,
    required: true,
    ref: 'users'
  },
  // 类型
  type: {
    type: String,
    required: true,
    enum: Object.values(ChatTypes)
  },
  // 状态
  status: {
    type: String,
    enum: Object.values(ChatStatus),
    default: ChatStatus.enable
  },
  // 消息内容
  message: {
    type: String,
    required: true
  }
}, {
  timestamps: true
});